#!/usr/bin/env python3
# encoding: utf-8

"""
@version: 1.0
@author: 周永波
@file: __init__.py.py
@time: 2020/8/13 10:55
"""
import json
import logging
import os
from decimal import Decimal

from flask import Flask
from flask_session import Session

from demoApp.setting.database import init_db_app, data_db
from demoApp import util
from demoApp.setting import setting
from demoApp.setting.es import ELS

from demoApp.util.serialization import JSONEncoder

logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')


app = Flask(__name__)
app.json_encoder = JSONEncoder
# 启动session
app.config['SECRET_KEY'] = os.urandom(24)
# Session(app)

# 配置管理
app_property = setting.property(os.path.dirname(__file__))
# 数据库配置
init_db_app('db', data_db(app, util.appUtils.dict_get(app_property.properties, ['db'])).db)
#es 配置
ELS(app_property.properties)
# 视图注册
from demoApp.setting.doc import DocSwagger
#swagger
DocSwagger(app)

from demoApp.setting.Register import Views, Filter, RestfulViews
from flask_restful import Api, Resource
# api = Api(app)
Views(app)
# RestfulViews(api)
Filter(app, app_property.properties)



from demoApp.models import baseInfo
